<script>
$(document).ready(function(){
	{params}
	var c = {
		info:{},
		init:function(){
			this.resize();
			this.cnum = params.cnum;
			
			js.ajax.get({
				url:'api/company/index',
				cnum:this.cnum,
				loading:'加载中...'
			}, function(ret){
				c.showdata(ret.data);
			});
		},
		resize:function(){
			//xcy.setheight('zongdiv{rand}',viewheight-30);
		},
		opendept:function(){
			addtabs({url:'flow/list','num':'dept'+this.cnum+'',name:'部门管理(单位)',params:{num:'dept',otype:'company','cnum':this.cnum}});
		},
		openusera:function(){
			addtabs({url:'flow/list','num':'usera'+this.cnum+'',name:'用户管理(单位)',params:{num:'usera',otype:'company','cnum':this.cnum}});
		},
		openoption:function(){
			addtabs({url:'flow/list','num':'option'+this.cnum+'',name:'数据选项(单位)',params:{num:'option',otype:'company','cnum':this.cnum}});
		},
		openmokuai:function(){
			addtabs({url:'flow/list','num':'flowunit'+this.cnum+'',name:'单位模块(单位)',params:{num:'flowunit',otype:'company','cnum':this.cnum}});
		},
		opencourse:function(){
			
		},
		showdata:function(da){
			this.info = da.info;
			$('#companynum{rand}').html(da.info.num);
			$('#companyname{rand}').html(da.info.name);
			$('#companynameshort{rand}').html(da.info.nameshort);
			$('#companyusershu{rand}').html(da.usershu);
			$('#companyusershuwjh{rand}').html(da.usershuwjh);
			if(da.info.logo){
				get('companylogo{rand}_img').src = da.info.logo;
				get('companylogo{rand}').value = da.info.logo;
			}
			this.showhmode(da.info.hmode);
		},
		showhmode:function(lx){
			var hmode = '菜单形式';
			if(lx=='1')hmode='IM形式';
			if(lx=='2')hmode='桌面形式';
			$('#companyhmode{rand}').html(hmode);
		},
		editname:function(){
			var o1 = $('#companyname{rand}');
			js.modal.prompt({
				title:'修改单位名称',
				value:o1.html(),
				msg:'请输入新的名称'
			}, function(jg,txt){
				if(jg=='yes' && txt){
					o1.html(txt);
					c.saveinfo('name',txt);
				}
			});
		},
		editnameshort:function(){
			var o1 = $('#companynameshort{rand}');
			js.modal.prompt({
				title:'修改单位简称',
				value:o1.html(),
				msg:'请输入新的简称'
			}, function(jg,txt){
				if(jg=='yes' && txt){
					o1.html(txt);
					c.saveinfo('nameshort',txt);
				}
			});
		},
		editlogo:function(){
			importjs('rockfile','changeface',{
				name:'单位Logo',
				fields:'companylogo{rand}',
				cnum:this.cnum,
				oncallback:function(str){
					c.saveinfo('logo',str);
				}
			});
		},
		saveinfo:function(fid,str){
			js.ajax.post({
				url:'api/company/save'+fid+'',
				cnum:this.cnum,
				data:{value:str}
			});
		},
		edithmode:function(){
			var cheka = ['','',''];
			cheka[this.info.hmode]='checked';
			var h = '<div style="padding:15px"><form name="edithmode">';
			h+='<div><label><input type="radio" '+cheka[0]+' value="0" name="hmode">菜单形式</label></div>';
			h+='<div><label><input type="radio" '+cheka[1]+' value="1" name="hmode">IM形式</label></div>';
			h+='<div><label><input type="radio" '+cheka[2]+' value="2" name="hmode">桌面形式(待开发)</label></div>';
			h+='<div></form></div>';
			var can = js.modal.main({
				title:'修改默认主页模式',
				width:300,height:200,
				html:h,
				btn:[{text:'确定修改'}]
			});
			$('#'+can.action+'_btn0').click(function(){
				var da = js.getformdata('edithmode');
				c.showhmode(da.hmode);
				c.saveinfo('hmode', da.hmode);
				c.info.hmode = da.hmode;
				js.tanclose(can.action)
			});
		},
		openindex:function(o1,lx){
			var d 	= this.info;
			var url = 'home';
			if(lx==1)url='company/homeim';
			var cans = {url:url,name:d.name,params:{cnum:d.num,title:d.name}}
			if(lx>0 && nwjs){
				js.location(xcy.openurl(cans));
			}else{
				xcy.openkey(cans);
			}
		}
	}
	
	js.initbtn(c)
});
</script>
<div style="padding:10px">

	<div style="margin-right:15px;float:left">
		<div style="padding:0px 5px 2px 10px;" class="hui fontsize12">管理</div>
		<div class="rock-panel rock-border rock-radius rock-list-group" style="width:180px;">
			<div clickevt="opendept" class="rock-list-item rock-hover">部门管理</div>
			<div clickevt="openusera" class="rock-list-item rock-hover">用户管理</div>
			<div clickevt="openoption" class="rock-list-item rock-hover">数据选项</div>
		</div>
		
		<div style="padding:15px 5px 2px 10px;" class="hui fontsize12">模块</div>
		<div class="rock-panel rock-border rock-radius rock-list-group" style="width:180px;">
			<div clickevt="openmokuai" class="rock-list-item rock-hover">单位模块</div>
			<div clickevt="opencourse" class="rock-list-item rock-hover">流程步骤</div>
		</div>
		
		<!--
		<div style="padding:15px 5px 2px 10px;" class="hui fontsize12">IM即时通信</div>
		<div class="rock-panel rock-border rock-radius rock-list-group" style="width:180px;">
			<div clickevt="opendept" class="rock-list-item rock-hover">会话管理</div>
			<div clickevt="opendept" class="rock-list-item rock-hover">会话记录</div>
		</div>
		-->
		
		<div style="padding:15px 5px 2px 10px;" class="hui fontsize12">进入单位主页</div>
		<div class="rock-panel rock-border rock-radius rock-list-group" style="width:180px;">
			<div clickevt="openindex,0" class="rock-list-item rock-hover">菜单形式</div>
			<div clickevt="openindex,1" class="rock-list-item rock-hover">IM形式</div>
			<div clickevt="openindex,2" class="rock-list-item rock-hover">桌面形式</div>
		</div>
		
	</div>

	<div id="zongdiv{rand}" style="height:600px;overflow:auto;float:left">
		
		<div style="min-width:280px" >
			<div align="center" style="padding:20px 0px">
				<div><img style="width:80px;height:80px;border-radius:50%" onclick="js.viewimg(this)" id="companylogo{rand}_img" src="images/nologo.png" align="absmiddle"></div>
				<input id="companylogo{rand}" type="hidden">
			</div>
		
			<div class="rock-panel rock-border rock-radius rock-list-group">
				
				<div class="rock-list-item">
					单位编号
					<font class="hui" ><span style="font-size:14px" id="companynum{rand}"></span></font>
				</div>
				<div class="rock-list-item rock-hover" clickevt="editlogo">
					修改Logo
					<font class="hui" ><i class="icon-angle-right"></i></font>
				</div>
				<div class="rock-list-item rock-hover" clickevt="editname">
					单位名称
					<font class="hui" ><span style="font-size:14px" id="companyname{rand}"></span>&nbsp;<i class="icon-angle-right"></i></font>
				</div>
				<div class="rock-list-item rock-hover" clickevt="editnameshort">
					单位简称
					<font class="hui"><span style="font-size:14px" id="companynameshort{rand}"></span>&nbsp;<i class="icon-angle-right"></i></font>
				</div>
				<div class="rock-list-item rock-hover" clickevt="edithmode">
					主页模式
					<font class="hui" ><span style="font-size:14px" id="companyhmode{rand}">菜单形式</span>&nbsp;<i class="icon-angle-right"></i></font>
				</div>
				<div class="rock-list-item">
					单位用户数
					<font><span class="rock-badge bg-success" id="companyusershu{rand}">0</span></font>
				</div>
				<div class="rock-list-item">
					单位用户未激活
					<font><span class="rock-badge bg-danger" id="companyusershuwjh{rand}">0</span></font>
				</div>
			</div>
		</div>
		
		
	</div>
</div>